package com.jessechanrui.template.shardingsphere.validated.dto;

import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Email;
import javax.validation.constraints.NotNull;

/**
 * 验证校验DTO
 * @author chenrui
 * @date 2024/2/29
 */
@Data
public class ValidatedDTO {

    @NotNull(message = "userId 一定不能为空")
    private Long userId;

    @NotNull
    @Length(min = 2, max = 10)
    private String userName;

    @NotNull(groups = {Save.class})
    @Length(min = 6, max = 20)
    private String account;

    @NotNull(groups = {Update.class})
    @Length(min = 6, max = 20)
    private String password;

    @NotNull
    @Email(groups = {Save.class, Update.class})
    private String email;


    /**
     * 保存的时候校验分组
     */
    public interface Save {
    }

    /**
     * 更新的时候校验分组
     */
    public interface Update {
    }
}
